import 'package:fish_redux/fish_redux.dart';

import 'action.dart';
import 'state.dart';

Reducer<IntegralAddressEditState> buildReducer() {
  return asReducer(
    <Object, Reducer<IntegralAddressEditState>>{
      IntegralAddressEditAction.action: _onAction,
      IntegralAddressEditAction.upSelectLb: _upSelectLb,
      IntegralAddressEditAction.upSwitch: _upSwitch,
      IntegralAddressEditAction.upPhone: _upPhone,
      IntegralAddressEditAction.upName: _upName,
      IntegralAddressEditAction.upArea: _upArea,
      IntegralAddressEditAction.upAddress: _upAddress,
    },
  );
}

IntegralAddressEditState _onAction(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  return newState;
}

IntegralAddressEditState _upSelectLb(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  newState.indexLb = action.payload;
  return newState;
}

IntegralAddressEditState _upSwitch(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  newState.valueSwitch = action.payload;
  return newState;
}
IntegralAddressEditState _upPhone(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  newState.phone = action.payload;
  return newState;
}
IntegralAddressEditState _upName(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  newState.name = action.payload;
  return newState;
}
IntegralAddressEditState _upArea(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  newState.area = action.payload;
  return newState;
}

IntegralAddressEditState _upAddress(IntegralAddressEditState state, Action action) {
  final IntegralAddressEditState newState = state.clone();
  newState.address = action.payload;
  return newState;
}
